home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / CPP / WFC010.ZIP / TEST / TCNSRC.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-21  |  1.4 KB  |  52 lines

  1. #include "test.h"
  2. #pragma hdrstop
  3.  
  4. void print_resource( CNetworkResourceInformation& information )
  5. {
  6.    printf( "\"%s\" - \"%s\" - \"%s\" - \"%s\"\n",
  7.            (LPCTSTR) information.LocalName,
  8.            (LPCTSTR) information.RemoteName,
  9.            (LPCTSTR) information.Comment,
  10.            (LPCTSTR) information.Provider );
  11. }
  12.  
  13. void test_CNetResource( void )
  14. {
  15.    CNetworkResources net_resource;
  16.  
  17.    CNetworkResourceInformation information;
  18.  
  19.    information.Scope = CNetworkResources::scopeAll;
  20.    information.Usage = CNetworkResources::usageConnectable | CNetworkResources::usageContainer;
  21.    information.Type  = CNetworkResources::typeDisk;
  22.  
  23.    if ( net_resource.Enumerate( information ) )
  24.    {
  25.       print_resource( information );
  26.  
  27.       while( net_resource.GetNext( information ) )
  28.       {
  29.          print_resource( information );
  30.       }
  31.  
  32.       DWORD error_code = net_resource.GetErrorCode();
  33.  
  34.       CString error_message;
  35.  
  36.       Convert_NERR_Code_to_String( error_code, error_message );
  37.  
  38.       printf( "CNetSession.ErrorCode == %d \"%s\"\n", error_code, (LPCTSTR) error_message );
  39.    }
  40.    else
  41.    {
  42.       DWORD error_code = net_resource.GetErrorCode();
  43.  
  44.       CString error_message;
  45.  
  46.       Convert_NERR_Code_to_String( error_code, error_message );
  47.  
  48.       printf( "CNetSession.ErrorCode == %d \"%s\"\n", error_code, (LPCTSTR) error_message );
  49.    }
  50. }
  51.  
  52.